﻿using Framework.Core;

namespace Framework.Remoting.Client
{
    public static class WcfExtension
    {
        public static void Close<T>(this T instance)
        {
            if (instance == null)
            {
                return;
            }

            try
            {
                var wcfInterceptor = instance.Get<WcfInterceptor<T>>();
                wcfInterceptor.Dispose();
            }
            catch (ProxyException e)
            {
                throw new WcfProxyException("bad proxy", e);
            }
        }
    }
}